package com.gupaoedu.demo.simplefactory;

public class CourseFactory {
    public ICourse create(String name){
        if("java".equals(name)){
            return new JavaCourse();
        }else{
            return null;
        }
    }

    public com.gupaoedu.demo.simplefactory.ICourse course(String className){
        try {
            if(null != className || !"".equals(className)){
               return (ICourse) Class.forName(className).newInstance();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public ICourse courseCreate(Class  clzz){
        try {
            if(null !=clzz ){
                return (ICourse) clzz.newInstance();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
